package com.base.task;

import com.base.task.em.BatchTypeEm;
import com.base.task.entity.BatchParam;

/**
 * @author: wangxs986
 * @date: 2022/8/27
 * @desc: 适配器
 **/
public abstract class AbstractBatchServerTarget implements BatchServerTarget {

    @Override
    public BatchServer normal(BatchParam param, IBatch server) {
        return BatchServer.builder(param, server);
    }

    @Override
    public BatchNoRepeatServer noRepeat(BatchParam param, IBatch server) {
        return BatchNoRepeatServer.builder(param, server);
    }

    protected BatchServerFactory init(BatchTypeEm type, BatchParam param) {
        BatchServerFactory factory = null;
        switch (type) {
            case NOREPEAT:
                factory = noRepeat(param, (IBatch) this);
                break;
            default:
                factory = normal(param, (IBatch) this);
        }
        return factory;
    }

}
